<?php
require_once('entities/UserGroup.php');

class GroupsModel
{
	public $groups;
	public function __contruct()
	{
		
	}
	public function getList()
	{
		global $entityManager;
		return $results = $entityManager->getRepository('UserGroup')->findAll();
	}
	public function delete($id)
	{
		global $entityManager;
		$temp = $entityManager->getRepository('UserGroup')->findBy( array('id' => $id ));
		if(!$temp) 
		{
			header('Location: index.php?com=com_user&view=groups');
			exit();
		}
		$entityManager->remove($temp[0]);
    	$entityManager->flush();
	}
	// public function check_exists_user($username){
	// 	global $entityManager;
	// 	$results = $entityManager->getRepository('User')->findBy( array('username' => $username ));
	// 	if ($results) {
	// 		return true;
	// 	}
	// 	else return false;
	// }
	// public function login($username,$password)
	// {
	// 	global $entityManager;
	// 	$results = $entityManager->getRepository('User')->findBy( array('username' => $username , 'password' => $password ));
	// 	 if($results) 
	// 	{
	// 		foreach ($results as $result) {
	// 			$_SESSION['username'] = $result->getUserName();
	// 			header('Location: index.php?com=com_user&view=info');
	// 		}
			
	// 	}
	// }
}